﻿using FastReport.Utils;

namespace FastReport.Export.PdfSimple
{
    partial class PDFSimpleExport : ExportBase
    {
        #region Private Fields

        private string author;
        private int imageDpi = 300;
        private int jpegQuality = 90;
        private string keywords;
        private string subject;
        private string title;

        #endregion Private Fields

        #region Public Properties

        /// <summary>
        /// Author of the document.
        /// </summary>
        public string Author
        {
            get { return author; }
            set { author = value; }
        }

        /// <summary>
        /// The resolution pdf images in scale by ImageDpi / 96, default value is 300. This is real dpi of images!
        /// Max value is 1200,  miv value is 96
        /// Of course, this only works for images generated by the FastReport engine, for other images, resolution is preserved.
        /// </summary>
        public int ImageDpi
        {
            get { return imageDpi; }
            set
            {
                if (value > 1200)
                    value = 1200;
                else if (value < 96)
                    value = 96;
                imageDpi = value;
            }
        }

        /// <summary>
        /// The quality of jpeg, default value is 90, max 100, min 10
        /// </summary>
        public int JpegQuality
        {
            get { return jpegQuality; }
            set
            {
                if (value > 100)
                    value = 100;
                else if (value < 10)
                    value = 10;
                jpegQuality = value;
            }
        }

        /// <summary>
        /// Keywords of the document.
        /// </summary>
        public string Keywords
        {
            get { return keywords; }
            set { keywords = value; }
        }

        /// <summary>
        /// Subject of the document.
        /// </summary>
        public string Subject
        {
            get { return subject; }
            set { subject = value; }
        }

        /// <summary>
        /// Title of the document.
        /// </summary>
        public string Title
        {
            get { return title; }
            set { title = value; }
        }

        #endregion Public Properties

        #region Public Methods

        /// <inheritdoc/>
        public override void Serialize(FRWriter writer)
        {
            base.Serialize(writer);

            writer.WriteInt("JpegQuality", JpegQuality);
            writer.WriteInt("ImageDpi", ImageDpi);

            writer.WriteStr("Title", Title);
            writer.WriteStr("Author", Author);
            writer.WriteStr("Subject", Subject);
            writer.WriteStr("Keywords", Keywords);
        }

        #endregion Public Methods
    }
}